package com.group.eams.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.group.eams.pojo.dto.SoftwareCategoryQueryDto;
import com.group.eams.pojo.entity.SoftwareCategory;
import com.group.eams.service.SoftwareCategoryService;
import com.group.eams.mapper.SoftwareCategoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author 恩哲欣
* @description 针对表【software_category(软件分类表)】的数据库操作Service实现
* @createDate 2024-10-29 16:09:34
*/
@Service
public class SoftwareCategoryServiceImpl extends ServiceImpl<SoftwareCategoryMapper, SoftwareCategory> implements SoftwareCategoryService{

    @Autowired
    private SoftwareCategoryMapper softwareCategoryMapper;

    /**
     * 根据查询条件查询
     *
     * @param softwareCategoryQueryDto 查询条件
     * @return 分页结果
     */
    @Override
    public Page<SoftwareCategory> findByQueryDto(SoftwareCategoryQueryDto softwareCategoryQueryDto) {
        Page<SoftwareCategory> page = new Page<>(softwareCategoryQueryDto.getPage(), softwareCategoryQueryDto.getLimit());
        LambdaQueryWrapper<SoftwareCategory> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper
                .like(!StrUtil.isEmpty(softwareCategoryQueryDto.getName()), SoftwareCategory::getName, softwareCategoryQueryDto.getName())
                .eq(softwareCategoryQueryDto.getStatus()!=null, SoftwareCategory::getStatus, softwareCategoryQueryDto.getStatus());
        return softwareCategoryMapper.selectPage(page, queryWrapper);
    }
}
